import { IGetCloseBtnVisibleParams } from "./interface";

/**
 * 判断列表上的/或者详情上的按钮是否展示
 * @param param0
 * @returns
 */
export const getCloseBtnVisible = ({
  busType = 1,
  record,
}: IGetCloseBtnVisibleParams) => {
  if (!record) {
    return false;
  }

  if (busType == 1) {
    return (
      record?.authorityModel?.cancel &&
      (record?.orderStatus == 54 || record?.orderStatus == 65) &&
      (record.cancelStatus == undefined || record.cancelStatus == 0) &&
      (record.closeStatus == undefined || record.closeStatus == 0)
    );
  }
  if (busType == 2) {
    return (
      record?.authorityModel?.close &&
      (record?.orderStatus == 54 || record?.orderStatus == 65) &&
      (record.closeStatus == undefined || record?.closeStatus == 0) &&
      (record.cancelStatus == undefined || record.cancelStatus == 0)
    );
  }

  if (busType == 3) {
    return (
      record?.authorityModel?.cancelClose &&
      (record?.orderStatus == 54 || record?.orderStatus == 65) &&
      (record.closeStatus == undefined || record.closeStatus == 2)
    );
  }
  return false;
};
